<template>
  <e-table :columns="columns" :data="data"></e-table>
</template>

<script setup>
const columns = [
  {
    title: '姓名',
    key: 'name',
    sortable: true
  },
  {
    title: '年龄',
    key: 'age',
    showFilterType: 'filterCheckbox',
    filters: [
      { label: '大于等于30', value: 0 },
      { label: '大于20小于30', value: 1 },
      { label: '小于等于20', value: 2, disabled: true}
    ],
    filteredValue: [],
    filterMultiple: false,
    filterMethod(value, row) {
      if (value === 0) {
        return row.age >= 30;
      } else if (value === 1) {
        return row.age < 30 && row.age > 20;
      } else if (value === 2) {
        return row.age <= 20;
      } else {
        return true
      }
    }
  },
  {
    title: '工作部门',
    key: 'occupation'
  }
]

const data = [
  {
    name: 'alfred',
    age: 36,
    occupation: 'IaaS',
  },
  {
    name: 'lily',
    age: 39,
    occupation: 'eIaaS',
  },
  {
    name: 'tom',
    age: 27,
    occupation: 'PaaS'
  },
  {
    name: 'jerry',
    age: 28,
    occupation: 'SaaS',
  },
  {
    name: 'dog',
    age: 15,
    occupation: 'IaaS',
  },
  {
    name: 'miaomiao',
    age: 18,
    occupation: 'IaaS',
  }
]
</script>